*****proportion of married parents in 25th national income percentile****
use cz coll_pooled_pooled_p25* married_pooled_pooled_p* has_dad_pooled_pooled_p* has_mom_pooled_pooled_p* two_par_pooled_pooled_p* kfr_pooled_pooled_p25 kfr_stycz_pooled_pooled_p25 using "$data/Opp_Atlas/cz_outcomes", clear
drop *_se
merge 1:1 cz using "$data/LOO/onlinedata8", keep(match) nogen
keep cz stateabbrv pop2000 has* two* married* coll* kfr*

su kfr*
replace pop2000 = subinstr(pop2000, ", ", "", .)
replace pop2000 = subinstr(pop2000, ",", "", .)
replace pop2000 = subinstr(pop2000, " ", "", .)
replace pop2000 = trim(pop2000)
destring pop2000, replace
collapse (mean) married* has* two* coll* kfr* [fw = pop2000], by(stateabbrv)

//merge on state fips codes
ren state state
merge m:1 state using "$data/Crosswalks/state_fips_crosswalk", keep(match) nogen

//clean up and save
drop if statefips == 11
keep statefips two_par_pooled_pooled_p25 married_pooled_pooled_p25 coll kfr*
save "$temp/chetty_marriage_data", replace

//export
keep statefips two_par_pooled_pooled_p25 coll kfr*
save "$temp/chetty_state_data_round2", replace

merge 1:1 statefips using "$temp/census_p25_marriage_rates", keep(match) nogen
su two_par married
corr married two_par
corr kfr_pooled_pooled_p25 kfr_stycz*
su kfr*


order statefips two
compress
sort statefips
export delimited "$dir/Model/utilities/parent_marriage_probs_p25.csv", replace novarn


//end of do-file
